<template>
  <div class="search-history">
    <van-cell title="搜索历史">
      <!-- 使用 title 插槽来自定义标题 -->
      <van-icon name="delete" @click="$emit('delAll')"></van-icon>
    </van-cell>
    <van-cell
      @click="onItemClick(item)"
      :title="item"
      v-for="(item, index) in searchHistory"
      :key="index"
    >
      <van-icon name="close" @click.stop="test(index)"></van-icon>
    </van-cell>
  </div>
</template>
<script>
export default {
  props: ['searchHistory'],
  name: 'history',
  created() {},
  computed: {},
  data() {
    return {}
  },
  methods: {
    test(index) {
      console.log(index)
      this.$emit('delete', index)
    },
    onItemClick(item) {
      console.log(item)
      this.$emit('changeValue', item)
    }
  }
}
</script>
<style lang="less" scoped></style>
